﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NCLCustomerManagement.DataAccess.NSHistory;
using NCLCustomerManagement.DataTransferObjects.History;

namespace NCLCustomerManagement.BusinessLogic.History
{
    public class HistoryBC : BaseBC, IHistoryBC
    {
        private IHistoryRepository _histRepository;

        public HistoryBC(IHistoryRepository histRepository)
        {
            _histRepository = histRepository;
        }

        public IEnumerable<HistoryDTO> GetLoginHistoryList(int pageIndex, int pageSize)
        {
            var list = _histRepository.GetHistoryListBy(HistoryType.Login);
            return list.Skip(pageIndex * pageSize).Take(pageSize);
        }

        public IEnumerable<HistoryDTO> GetOtherOperationsHistoryList(int pageIndex, int pageSize)
        {
            var list = _histRepository.GetHistoryListBy(HistoryType.Other);
            return list.Skip(pageIndex * pageSize).Take(pageSize);
        }

        public override My.DataAccess.Core.IBaseRepository<DTO> GetRepository<DTO>()
        {
            return _histRepository as My.DataAccess.Core.IBaseRepository<DTO>;
        }


        public void AddHistory(HistoryDTO dto)
        {
            _histRepository.AddHistory(dto);
        }
    }
}
